package com.x.Part8_多态;

/**
 * ClassName: Income
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2023/10/20 9:51
 */

class Income {
    protected double income;
    public Income(double income){
       this.income = income;
    }
    public double getTax(){
        return income * 0.1;
    }
}

class Salary extends Income{

    public Salary(double income){
        super(income);
    }
    @Override
    public double getTax(){
        if (income <= 5000)
            return 0;
        return (income - 5000) * 0.2;
    }
}

class SpecialAllowance extends Income{
    public SpecialAllowance(double income){
        super(income);
    }
    @Override
    public double getTax(){
        return 0;
    }
}


